package top.continew.minithreadpool.policy;

import sun.nio.ch.ThreadPool;
import top.continew.minithreadpool.concurrent.ThreadPoolExecutor;

import java.util.concurrent.RejectedExecutionException;

/**
 * 拒绝策略：直接抛出异常
 */
public class AbortPolicy implements RejectedExecutionHandler {
    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        throw new RejectedExecutionException("任务 " + r.toString() +
                " 被拒绝 (" + executor.toString() + ")");
    }
}
